#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Date    : 2017-05-03 22:03:57
# @Author  : yangxinpeng (yxpeng25877@gmail.com)
# @Link    : ${link}
# @Version : $Id$
# for x in range(1, 11):
#      print repr(x).rjust(2), repr(x*x).rjust(3),
#      # Note trailing comma on previous line
#      print repr(x*x*x).rjust(4)
import sys
print(sys.platform)
print(2 ** 100)
# 全局变量   变量命名原则：
x='span'

print(x * 8)
	# 中国人
# 函数定义
def add(x,y):
	# y为局部变量
	z=x+y
	return z

# 函数调用
res=add(2,3)
print res
# 列表
demlist=[1,2,3]
demlist.append(5)
print len(demlist)
print demlist
print  demlist[2]
maptest={
'a':"1",
'a1':1,
'a2':234,
'a3':"1",
}
print maptest['a']

for key in maptest:
	maptest[key]
	print maptest[key]

class Employee(object):
	"""docstring for ClassName"""
	# 共有类变量
	g="dfdd"
	# 私有类变量
	__y='kdkfd'

	def __init__(self, arg):
		self.arg = arg
	def  a(self):
		print 'rrrrr'
	def sayHello(self):
		print 'word'
xiao=Employee("cc")
xiao.a()
# xiao.sayHello()
dir(xiao)
class Emp(Employee):
	"""docstring for ClassName"""

	def __init__(self, arg):
		self.arg = arg
	def sayHello(self):
		# Employee().sayHello()
		print 'hello'
	# 类方法 可以操作类属性，不论共有还是私有变量	
	@classmethod
	def  abc(self):
		print "fdsjfs"


xiaohong=Emp('dd')
xiaohong.sayHello()


#变量的python内存地址查看：id(变量名)
def pyAdress():
	a=3
	b=a
	print (id(a))
	print(id(b))
	# id(a)
	# id(b)
	return b

pinAdress=pyAdress()
f=pyAdress
ret=f()
print(ret)
# python利用缩进确定一段代码中的作用域

sex='g'
if(sex=="g"):
	print("aaaaaa")
	print("bbbb")
elif(sex=="m"):
	print("ccccc")
	print("dddd")
else:
	print("eeeee")

def  tryCatchDemo(par1):
	try:
		if (par1=="2"):
			print("*******" "KKKKKK")
	except Exception, e:
			print("KK222222")
			raise e
	finally:
		pass

tryCatchDemo('2')


